﻿package  
{
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.net.URLRequest;
	import idv.etrex.compression.XGraphicsDownsampler;
	import idv.etrex.display.object.DynamicMask;
	import idv.etrex.display.XGraphics;
	import idv.etrex.display.XGraphicsLoader;
	
	/**
	 * ...
	 * @author etrex
	 */
	public class XGraphihcsDownsampleTool extends Sprite
	{	/*
		var loader:Loader = new Loader();
		var wwidth;
		var hheight;
		var xgp:String;
		var imagep:String;
		var xg:XGraphics;
		var xml:XML;
		var xgLoader:XGraphicsLoader = new XGraphicsLoader();
		
		var dmArray:Array = new Array();
		*/
		
		var xgLoader:XGraphicsLoader = new XGraphicsLoader();
		
		public function XGraphihcsDownsampleTool() 
		{
			xgLoader.addEventListener(Event.COMPLETE, xgLoaderComplete);
			xgLoader.load("2.xg");
			/*
			//loader event
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE,loaderComplete);
			xgLoader.addEventListener(Event.COMPLETE, xgLoaderComplete);
			//button event
			loadFileButton.addEventListener(MouseEvent.CLICK, loadFileButtonClick);
			*/
		}
		public function xgLoaderComplete(e:Event):void {
			var xgd:XGraphicsDownsampler = new XGraphicsDownsampler(xgLoader.xgraphics);
			trace(xgd.downSample(5));
		}
		
		/*
		//load File Button Event
		private function loadFileButtonClick(event:MouseEvent):void {
			trace("loadFileButtonClick");
			xgp = xgPath.text;
			imagep = imagePath.text;
			loader.load(new URLRequest(imagep));
		}
		
		public function loaderComplete(e:Event):void {
			wwidth = loader.width;
			hheight = loader.height;
			loadDM();
			//xgLoader.load(xgp);
		}
		
		public function xgLoaderComplete(e:Event):void {
			//loadDM();
		}
		public function loadDM():void {
			for (var i:int = 0; i < 10 ; i++)
			{
				var dm:DynamicMask = new DynamicMask();
				dm.loadFromFile(imagep, xgp);
				dm.onReady = dmOnReady;
				
				
				
				this.addChild(dm);
			}
		}
		
		public function dmOnReady():void {
			var i = dmArray.indexOf(this)+2;
			this.xgraphics = 
		}
		*/
	}

}